<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" id="form-user-resetPwd">
			<input name="userId"  type="hidden"  th:value="${user.userId}" />
			<div class="form-group">
				<label class="col-sm-2 control-label ">登录名称：</label>
				<div class="col-sm-8">
					<label class="control-label" th:text="${user.loginName}"></label>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">密码：</label>
				<div class="col-sm-9">
					<input class="form-control" type="password" name="oldPassword" id="oldPassword">
				</div>
			</div>
			<div class="form-group" th:each="obj,objIndex:${secrets}">
				<label class="col-sm-2 control-label" th:text="${'密保问题'+(objIndex.index+1)+'：'}"></label>
				<div class="col-sm-4">
					<input class="form-control" type="text" th:name="${'question'+objIndex.index}" th:value="${obj.question}">
				</div>
				<div class="col-sm-5">
					<input class="form-control" type="text" th:name="${'answer'+objIndex.index}" placeholder="问题答案">
				</div>
			</div>
		</form>
	</div>
	<div th:include="include :: footer"></div>

	<script>
		$("#form-user-resetPwd").validate({
			rules:{
				oldPassword:{
					required:true,
					remote: {
	                    url: ctx + "system/user/checkPassword",
	                    type: "get",
	                    dataType: "json",
	                    data: {
	                        password: function() {
	                            return $("input[name='oldPassword']").val();
	                        }
	                    }
	                }
				},
                question1: {
	                required: true,
	            },
                answer1: {
	                required: true,
	            },
                question0: {
	                required: true,
	            },
                answer0: {
	                required: true,
	            }
			},
			messages: {
	            oldPassword: {
	                required: "请输入原密码",
	                remote: "原密码错误"
	            }

	        }
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
	        	$.operate.save(ctx + "system/user/updateSecret", $('#form-user-resetPwd').serialize());
	        }
	    }
	</script>
</body>

</html>
